SD-2281 - fix: page number on footer not properly aligned#2725
SD-2281 - fix: page number on footer not properly aligned#2725chittolinag wants to merge 2 commits intomainfrom
Conversation
…ber-textbox-overlaps-footer-text
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f92d0f8016
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (typeof footerDistance === 'number' && Number.isFinite(footerDistance)) { | ||
| return pageHeight - Math.max(0, footerDistance); |
There was a problem hiding this comment.
Clamp footer-origin math before normalizing footer anchors
The new footer-distance branch can produce a negative band origin when margins.footer > pageHeight (computeFooterBandOrigin returns pageHeight - footerDistance without clamping). In that case normalizeFragmentsForRegion writes fragment.y using a negative origin, but DomPainter’s getDecorationAnchorPageOriginY clamps the same expression to >= 0, so the two stages disagree and page-relative footer media render shifted by the clamp delta. This creates deterministic misplacement for malformed-but-parseable section margins and is introduced by this footer-distance path.
Useful? React with 👍 / 👎.
Issue
Floating page-number text boxes overlapped footer text because page-relative anchors were normalized against the bottom margin instead of the footer distance, with the incorrect origin cascading into DomPainter and cache reuse.
Proposed solution
Thread the footer distance through header/footer constraints, normalize footer anchors using that distance (with a bottom-margin fallback), update cache hashing to include the new geometry, and teach DomPainter to convert page-relative footer anchors using the same origin so floating page numbers sit beneath footer content.